package top.tony.base.service;

import top.tony.base.dao.IBaseDao;
import top.tony.base.pagenation.PageModel;
import top.tony.base.pagenation.BaseQueryObject;

import java.io.Serializable;
import java.util.List;

/**
 * Created by Tony_Du on 2015/12/3 0003.
 */
public abstract class BaseServiceImpl<Entity> implements IBaseService<Entity> {

    private IBaseDao<Entity> dao;

    public BaseServiceImpl(IBaseDao<Entity> dao) {
        this.dao = dao;
    }

    public Serializable save(Entity entity) {
        return dao.save(entity);
    }

    public int delete(Serializable id) {
        return dao.delete(id);
    }

    public void update(Entity entity) {
        dao.update(entity);
    }

    public Entity get(Serializable id) {
        return dao.get(id);
    }

    public List<Entity> getAll() {
        return dao.getAll();
    }

    public PageModel<Entity> pageQuery(BaseQueryObject queryObejct) {
        return dao.pageQuery(queryObejct);
    }

    public <VO> PageModel<VO> voPageQuery(Class<VO> voClass, BaseQueryObject queryObejct) {
        return dao.voPageQuery(voClass,queryObejct);
    }
}
